package com.sumainfor.pc.market.controller.rentadviser;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.market.service.RdTenantTrailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Date 2018年11月7日
 * @Describe 工程部查询房源配置
 */
@RestController
@RequestMapping("/rentadviser/RdTenantTrailController")
public class RdTenantTrailController implements Serializable {
    @Autowired
    private RdTenantTrailService rdTenantTrailService;
    /**
     * 新增跟踪状态
     */
    @PostMapping("/addTenantTrail")
    public JsonResult addTenantTrail (@RequestBody Map<String,Object> params) {
        JsonResult result = new JsonResult();
        int count=rdTenantTrailService.addTenantTrail(params);
        if (count>0){
            result.putSuccess("新增成功");
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 放弃跟踪状态
     */
    @PostMapping("/addTenantTrailAbandon")
    public JsonResult addTenantTrailAbandon (@RequestBody Map<String,Object> params) {
        return rdTenantTrailService.addTenantTrailAbandon(params);
    }
    /**
     * 查询历史跟踪状态
     */
    /**
     * 分页查询客户池
     * @param params
     * @param pager
     * @return
     */
    @GetMapping("/getTenantTrailList")
    public JsonResult getTenantTrailList(@RequestParam Map<String,Object> params, Pager pager){
        JsonResult result=new JsonResult();
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout=rdTenantTrailService.getTenantTrailListCount(params);
        if(cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
        }
        List<Map<String,Object>> getCommunityList=rdTenantTrailService.getTenantTrailList(params);
        result=pageUtils.getJsonResult(getCommunityList, params, cout);
        return result;
    }
}
